import type { App } from 'vue'
import { loadYoga } from 'yoga-layout/load'
import FlexNode from './FlexNode.vue'
import FlexRoot from './FlexRoot.vue'

export default {
  async install(app: App) {
    try {
      const Yoga = await loadYoga()
      app.provide('Yoga', Yoga) // 使用 provide 提供 Yoga 实例

      // 使用 kebab-case 命名
      app.component('flex-node', FlexNode)
      app.component('flex-root', FlexRoot)
      console.log('Yoga 加载完成，组件已注册')
    } catch (error) {
      console.error('Yoga 加载失败:', error)
    }
  }
}

export { FlexNode, FlexRoot }
